'''
    编写程序,按用户输入的三角形3条边判断能否构成直角三角形,若能够成则计算三角形的面积和周长,否则引发异常.
'''
class RightAngleError(Exception):
    def __init__(self,edge_one,edge_two,edge_three):
        self.edge_one = edge_one
        self.edge_two = edge_two
        self.edge_three = edge_three
    def __str__(self):
        return f'{self.edge_one},{self.edge_two},{self.edge_three}无法构成直角三角形'

def area_calc():
    try:
        edge_one = float(input('请输入第一条直角边边长:'))
        edge_two = float(input('请输入第二条直角边边长:'))
        edge_three = float(input('请输入斜边边长:'))
        if edge_one**2 + edge_two**2 != edge_three**2:
            raise RightAngleError(edge_one,edge_two,edge_three)
        area = (edge_one * edge_two) / 2
        print('三角形面积为',area)
    except RightAngleError as e:
        print(e)
area_calc()
